function historyPage(p){
		$.ajax({
			url : "system/loadHistory.sls",
			type : "post",
			data : {"page":p},
			dataType : "json",
			success : function(result) {
				$("#history_tbody").empty();
				if(result.status == 0){
					var historys = result.data;
					for(var i=0;i<historys.length;i++){
						var roll = historys[i].roll;
						if(roll==0){
							rolls = "总裁";
							deleteElement = '';
						} else if(roll == 1){
							rolls = "经理";
						} else {
							rolls = "员工";
						}
						var date = new Date(historys[i].enrolldate);
						var dateOut = new Date(historys[i].outdate);
						var x = dateOut.toLocaleString();
						if(historys[i].enrolldate == historys[i].outdate){
							x = new Date(historys[i].outdate+30*60*1000).toLocaleString();
						}
						var s = '<tr><td>'+historys[i].adminCode+'</td><td>'+historys[i].empId+'</td><td>'+historys[i].empName+'</td>'+
						'<td>'+rolls+'</td>'+
						'<td>'+date.toLocaleString()+'</td>'+
						'<td>'+x+'</td>'+
						'</tr>';
						var $tr = $(s);
						$tr.data("historyId",historys[i].historyId);
						$("#history_tbody").append($tr);
					}

					$.ajax({
						url : "system/historyPage.sls",
						type : "post",
						dataType : "json",
						success : function(result) {
							if(result.status == 0 ){
								var page = result.data.page;
								var total = result.data.total;
								var top ;
								var end ;
								var pageBody = "";
								if(page == 1){
									top = '<a>上一页</a>';
								} else {
									top = '<a href="javascript:historyPage('+(page-1)+');">上一页</a>';
								}
								if(page == total){
									end = '<a>下一页</a>';	
								} else {
									end = '<a href="javascript:historyPage('+(page+1)+');">下一页</a>';
								}
								var i=1;
								var m=5;
								if(page>2){
									i = page-2;
									m = page+2;
								}
								if(m>total){
									i=i-2;
									m = total;
								}
								if(page==total-1){
									i=page-3;
								}
								if(i<=0){
									i=1;
								}
								for(i;i<=m;i++){
									if(i==page){
										pageBody+='<a href="javascript:historyPage('+i+');" style="font-weight:bold;color:#8d341f;">'+i+'</a>';
									} else {
										pageBody+='<a href="javascript:historyPage('+i+');">'+i+'</a>';
									}
								}
								var s = top+pageBody+end;									
								$("#history_page").html(s);
							}
						},
						error : function(){
							window.location.href="error.sls";
						}
					});
				}
				
			},
			error : function(){
				window.location.href="error.sls";
			}
		});
}


function printAll(){
	location.href = "toExcel.sls";
}